home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / Internet / Misc / Uupc 3.1 sources.sit / uupc 3.1 sources Folder / Mac specific / hostpaths.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-22  |  2.4 KB  |  124 lines  |  [TEXT/KAHL]

  1. #ifdef THINK_C
  2. # include "unixlibproto.h"
  3. #endif THINK_C
  4.  
  5. #include    "host.h"
  6. #ifndef NULL
  7. #define NULL 0L
  8. #endif
  9.  
  10. #include "hostpaths.proto.h"
  11.  
  12. /* canonical name conversion routines
  13.  
  14.     importpath    canonical -> host
  15.     exportpath    host -> canonical
  16.  
  17.     host        your local pathname format
  18.     canonical    unix style
  19. */
  20.  
  21. importpath(char *host, char *canon)
  22. {
  23.     int i;
  24.     strcpy(host, canon);
  25. }
  26.  
  27. exportpath(char *canon, char *host)
  28. {
  29.     /* copy the string replacing ":" by "/" */
  30.     register    char *h = host,
  31.                      *c = canon;
  32.                         
  33.     while (*c = *h++) {
  34.         if (*c == ':') *c = '/';
  35.         c++;
  36.     }
  37. }
  38.  
  39. /* converts Unix path to Mac path syntax */
  40. /* Permit full Mac-style "diskname:dir:dir:...:file" specifications... dplatt */
  41. cnvMac (char *upath, char *mpath)
  42. {
  43.     register    char    *u = upath,
  44.                         *m = mpath;
  45.     int            vRef, len;
  46.     
  47.     if (*u == SEPCHAR) {
  48.         /* put volume name on the front */
  49.         (void)GetVol((StringPtr)m, &vRef);
  50.         len = (int)(m[0]);
  51.         PtoCstr(m);
  52.         m += len;
  53.     }
  54.     else if (strchr(u, DIRCHAR) == NULL) {
  55.         *m++ = ':';
  56.     }
  57.     
  58.     while ( *m = *u++ ) {
  59.         if (*m == SEPCHAR) *m = ':';
  60.         m++;
  61.     }
  62. }
  63.  
  64. /*
  65.    Do ugly character-remapping on Mac files to avoid collisions between
  66.    uppercase and lowercase letters.  Gaak.  Letters in the A-Z range are
  67.    mapped up into a range of accented lowercase letters.
  68.    
  69.    Handle names of the sort "L.xxxx" or ":L.xxxx" (where L is any capital letter)
  70.    on the assumption that these are spool-directory message files.  Leave other file
  71.    names unbashed, for lack of a more universal solution to the problem.
  72.    
  73.    Fixed reverse-mapping code for 3.1b30 so that it doesn't blow its mind if some
  74.    program has dropped in a file whose name wasn't character-mapped.  Older versions
  75.    became seriously dazed and confused.
  76. */
  77.  
  78. void mapMacCaseness(char *mpath)
  79. {
  80.   char *c;
  81.   if (mpath[0] == DIRCHAR) {
  82.       c = mpath + 1;
  83.   } else if (strchr(mpath, DIRCHAR) == NULL) {
  84.       c = mpath;
  85.   } else {
  86.       return;
  87.   }
  88.   if (c[1] != '.' || c[0] < 'A' || c[1] > 'Z') {
  89.     return;
  90.   }
  91.   c += 2;
  92.   while (*c) {
  93.     if (*c >= 'A' && *c <= 'Z') {
  94.       *c += 0x46;
  95.     }
  96.     c++;
  97.   }
  98. }
  99.  
  100. void unmapMacCaseness(char *mpath)
  101. {
  102.   char *c, cc;
  103.   if (mpath[0] == DIRCHAR) {
  104.       c = mpath + 1;
  105.   } else if (strchr(mpath, DIRCHAR) == NULL) {
  106.       c = mpath;
  107.   } else {
  108.       return;
  109.   }
  110.   if (c[1] != '.' || c[0] < 'A' || c[1] > 'Z') {
  111.     return;
  112.   }
  113.   c += 2;
  114.   while (cc = *c) {
  115.       if (cc >= 'A' + 0x46 && cc <= 'Z' + 0x46) {
  116.       *c = cc - 0x46;
  117.     }
  118.     c++;
  119.   }
  120. }
  121.  
  122.  
  123.  
  124.